package hk.m4s.lr.repair.test.ui.goods;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import framework.common.baseui.UeBaseActivity;
import hk.m4s.lr.repair.test.R;
import hk.m4s.lr.repair.test.model.JiangliModel;
import hk.m4s.lr.repair.test.ui.adapter.SelectListAdapter;

/**
 * Created by qi.wang on 2017/11/30.
 * 确认订单
 */

public class OrderSureActivity extends UeBaseActivity{
    private RelativeLayout show_layout;
    private ListView jiangli_list;
    private TextView send_name;
    private List<JiangliModel> jiangliList = new ArrayList<>();
    private SelectListAdapter adapter;
    private Context context;
    private String sendName;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        hiddenFooter();
        showGoBackBtn();
        setTitleText("确认订单");
        context=this;
        baseSetContentView(R.layout.activity_order_sure);
        showView();
    }
    public void showView(){
        show_layout=(RelativeLayout)findViewById(R.id.show_layout);
        jiangli_list=(ListView)findViewById(R.id.jiangli_list);
        send_name=(TextView)findViewById(R.id.send_name);
        jiangli_list.setOnItemClickListener(clickItem);
        JiangliModel model=new JiangliModel();
        model.setName("自提");
        model.setState("1");
        model.setId("1");
        jiangliList.add(model);
        JiangliModel models=new JiangliModel();
        models.setName("物流");
        models.setState("2");
        models.setId("2");
        jiangliList.add(models);
        adapter=new SelectListAdapter(context,jiangliList);
        jiangli_list.setAdapter(adapter);
    }
    public void onClick(View view){
        switch (view.getId()){
            case R.id.click_select_coupon:
                Intent intent=new Intent(OrderSureActivity.this,SlectCouponActivity.class);
                startActivity(intent);
                break;
            case R.id.click_select_send:
                show_layout.setVisibility(View.VISIBLE);
                break;
            case R.id.click_select_money:
                Intent intents=new Intent(OrderSureActivity.this,SelectMoneyActivity.class);
                startActivity(intents);
                break;
            case R.id.btn_cancle:
                show_layout.setVisibility(View.GONE);
                sendName="";
                break;
            case R.id.btn_sure:
                show_layout.setVisibility(View.GONE);
                send_name.setText(sendName);
                break;
            case R.id.take_buy:
                Intent payIntents=new Intent(OrderSureActivity.this,PayMoneyActivity.class);
                startActivity(payIntents);
                break;
        }
    }
    AdapterView.OnItemClickListener clickItem = new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                                long arg3) {
            // TODO Auto-generated method stub

                JiangliModel model = jiangliList.get(arg2);
                adapter.flag = arg2;
                adapter.notifyDataSetChanged();
                sendName = model.getName();

        }

    };
}
